<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.util.HashMap" %>
<%@include file="/include/common/formbackhead.jsp"%>
<%!
private class PageAction extends BaseAction{
	//加載頁面默認數據
	protected boolean onLoadDefault() throws Exception{
		onSearch();
		return true ;
	}
	
	protected void onSearchRetrieveResult() throws Exception{
		//lev1
		StringBuffer sql = new StringBuffer("select '├─'+rtrim(convert(char(10),sot))+des1 as lev1,item_no,des1,url,sot,fitem into #lev1 from js_system..wprg_item where fitem = 0 and flg = 1 order by sot");
		ResultSet rs1 = utils.executeQuery("info6",sql.toString()+" \r\n "+"select * from #lev1");
		ret.SetSearchResult(rs1);
		
		//lev2
		Map map2 = new HashMap();
		sql.append("\r\n select '　　├─'+rtrim(convert(char(10),a.sot))+a.des1 as lev2,a.item_no,a.des1,a.url,a.sot ,a.fitem into #lev2 from js_system..wprg_item a , #lev1 b where a.fitem = b.item_no and a.flg = 1 order by b.sot,a.sot");
		ResultSet rs2 = utils.executeQuery("info6",sql.toString()+" \r\n "+"select * from #lev2");
		while(rs2.next()){
			String key = utils.getRsString(rs2,"fitem");
			List subList = null;
			if(map2.containsKey(key)){
				subList = (List)map2.get(key);
			}else{
				subList = new ArrayList();
				map2.put(key,subList);
			}
			String[] ay = new String[3];
			ay[0] = utils.getRsString(rs2,"lev2");
			ay[1] = utils.getRsString(rs2,"item_no");
			ay[2] = utils.getRsString(rs2,"url");
			subList.add(ay);
		}
		ret.SetParamValue("lev2",map2);
		
		//lev3
		Map map3 = new HashMap();
		sql.append("\r\n select '　　　　├─'+rtrim(convert(char(10),a.sot))+a.des1 as lev3,a.item_no,a.des1,a.url,a.sot ,a.fitem into #lev3 from js_system..wprg_item a , #lev2 b where a.fitem = b.item_no and a.flg = 1 order by b.sot,a.sot");
		ResultSet rs3 = utils.executeQuery("info6",sql.toString()+" \r\n "+"select * from #lev3");
		while(rs3.next()){
			String key = utils.getRsString(rs3,"fitem");
			List subList = null;
			if(map3.containsKey(key)){
				subList = (List)map3.get(key);
			}else{
				subList = new ArrayList();
				map3.put(key,subList);
			}
			String[] ay = new String[3];
			ay[0] = utils.getRsString(rs3,"lev3");
			ay[1] = utils.getRsString(rs3,"item_no");
			ay[2] = utils.getRsString(rs3,"url");
			subList.add(ay);
		}
		ret.SetParamValue("lev3",map3);
		
		//lev4
		Map map4 = new HashMap();
		sql.append("\r\n select '　　　　　├─'+rtrim(convert(char(10),a.sot))+a.des1 as lev4,a.item_no,a.des1,a.url,a.sot ,a.fitem into #lev4 from js_system..wprg_item a , #lev3 b where a.fitem = b.item_no and a.flg = 1 order by b.sot,a.sot");
		ResultSet rs4 = utils.executeQuery("info6",sql.toString()+" \r\n "+"select * from #lev4");
		while(rs4.next()){
			String key = utils.getRsString(rs4,"fitem");
			List subList = null;
			if(map4.containsKey(key)){
				subList = (List)map4.get(key);
			}else{
				subList = new ArrayList();
				map4.put(key,subList);
			}
			String[] ay = new String[3];
			ay[0] = utils.getRsString(rs4,"lev4");
			ay[1] = utils.getRsString(rs4,"item_no");
			ay[2] = utils.getRsString(rs4,"url");
			subList.add(ay);
		}
		ret.SetParamValue("lev4",map4);
		
		//lev5
		Map map5 = new HashMap();
		sql.append("\r\n select '　　　　　　├─'+rtrim(convert(char(10),a.sot))+a.des1 as lev5,a.item_no,a.des1,a.url,a.sot ,a.fitem into #lev5 from js_system..wprg_item a , #lev4 b where a.fitem = b.item_no and a.flg = 1 order by b.sot,a.sot");
		ResultSet rs5 = utils.executeQuery("info6",sql.toString()+" \r\n "+"select * from #lev5");
		while(rs5.next()){
			String key = utils.getRsString(rs5,"fitem");
			List subList = null;
			if(map5.containsKey(key)){
				subList = (List)map5.get(key);
			}else{
				subList = new ArrayList();
				map5.put(key,subList);
			}
			String[] ay = new String[3];
			ay[0] = utils.getRsString(rs5,"lev5");
			ay[1] = utils.getRsString(rs5,"item_no");
			ay[2] = utils.getRsString(rs5,"url");
			subList.add(ay);
		}
		ret.SetParamValue("lev5",map5);
		
	}
	
}
%>
<%@include file="/include/common/formbackend.jsp"%>
